import { getDevDetail, getDevBasicInfo } from '../services/api';

export default {
  namespace: 'devInfo',

  state: {
    devInfo: {},
    devBasicInfo: {},
  },

  effects: {
    *fetch({ payload }, { call, put }) {
      const response = yield call(getDevDetail, payload);
      //console.log('response', response);
      yield put({
        type: 'save',
        payload: response.devInfoDet,
      });
    },
    *fetchBasicInfo({ payload }, { call, put }) {
      const response = yield call(getDevBasicInfo, payload);
      //console.log('response', response);
      yield put({
        type: 'basicInfo',
        payload: response.devBasicInfo,
      });
    },
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        devInfo: action.payload,
      };
    },
    basicInfo(state, action) {
      return {
        ...state,
        devBasicInfo: action.payload,
      };
    },
  },
};
